pp108 : Triggering a Business Process Model from an XForm

Triggering a Business Process Model from an XForm

This topic describes the procedure to trigger a business process model from an XForm.

Before you begin this task:

  • Ensure that the Cordys Business Process Designer, Cordys Business Process Engine, and Cordys Notification application packages (including all dependencies) are installed, and the appropriate roles of each application package are assigned to you, as applicable.
  • Ensure that the e-mail address is specified in the CUSP Preferences. To use MS Outlook, ensure that the Process Platform E-mail Connector application package is installed. If the notification is to be sent to the Inbox, ensure that the Inbox menu is available to you.

A Business Process Model is an executable model that comprises a set of activities or processes designed to produce a specific output. A business process model can be designed for a particular type of customer or market. The activities in a business process model may be automatic or may require manual intervention to proceed.

In business process model scenarios requiring manual inputs, you can use XForms to capture user specifications. For example, an XForm can be used in a workflow that involves the approval of a leave request. Alternately, XForms can be used to initialize a business process model.

As an example, consider a business scenario where you fill a loan application to apply for a loan. After you fill in the necessary set of details in the form, and click the Submit button, the loan process begins. Clicking Submit triggers a business process model that uses the inputs that you provided to process your loan request. Consider the following table for this business process:

In this case, the data will be provided in the above fields, and clicking the Submit button will trigger the business process model. To use the data provided in the fields, a model must be attached to the XForm.

  1. Identify the data required, and create the appropriate XForm.
  2. Add the following XML to the XML Editor of the XForm:
    <xml id="loanrequest">
        <LoanRequest xmlns="http://schemas.cordys/com/loanrequest">
            <Name/>
            <Phone/>
            <Income/>
            <PropertyValue/>
            <RequestedAmount/>
        </LoanRequest>
    </xml>
    

    This XML represents the data to be provided in the XForm.

  3. Create a non-transactional model, and bind it to the controls in the XForm. For more information, refer to Creating Models. In this case, a data model called LoanModel is created and bound using the Init Done event of the XForm.
    function Form_InitDone(eventObject) { //Bind model to empty data when the form loads LoanModel.putData(cordys.cloneXMLDocument(loanrequest.XMLDocument),true); }
  4. Create a non-transactional Model that uses the ExecuteProcess Web service operation to fire a request to initiate the business process model from the XForm. In this case, add the following XML to the XML Editor:
    <xml id="executeprocess">
        <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
            <SOAP:Body>
                <ExecuteProcess xmlns="http://schemas.cordys.com/bpm/execution/1.0">
                    <type>definition</type>
                    <receiver>3.Business Process Models/LoanApproval_northwind1.0.bpm</receiver>
                    <message>
                        <Input/>
                    </message>
                </ExecuteProcess>
            </SOAP:Body>
        </SOAP:Envelope>
    </xml>
    

    This XML creates a non-transactional model called BPMModel that fires the request to be sent to the Business Process Management service container to initiate the business process model. The XML contains only the mandatory parameters that are required to start the business process model. Now, the ExecuteProcess Web service operation is associated with data.

  5. Write the code to send requests to the business process model. Add the following code for the onclick event of the Submit button.
    function btnSubmit_Click(eventObject)
    {
    //Get the request for execute process
    var request = cordys.cloneXMLDocument(executeprocess.XMLDocument);
    //Get data from what customer typed
    var data = cordys.cloneXMLDocument(LoanModel.getData());
    //put data inside the request, and send request
    var inputNode = cordys.selectXMLNode(request,".//*[local-name()='Input']");
    cordys.appendXMLNode(data.documentElement,inputNode);
    BPMModel.setMethodRequest(request);
    BPMModel.reset();
    }

    This code sends a request with the specified input parameters to the business process model, and the business process model is started.

The XForm from which you can trigger the business process model is created.